<!doctype html>

<html>
<head>
  <link rel="shortcut icon" href="static/images/favicon.ico" type="image/x-icon">
  <title>fieldmock.js (Closure Library API Documentation - JavaScript)</title>
  <link rel="stylesheet" href="static/css/base.css">
  <link rel="stylesheet" href="static/css/doc.css">
  <link rel="stylesheet" href="static/css/sidetree.css">
  <link rel="stylesheet" href="static/css/prettify.css">

  <script>
     var _staticFilePath = "static/";
     var _typeTreeName = "goog";
     var _fileTreeName = "Source";
  </script>

  <script src="static/js/doc.js">
  </script>


  <meta charset="utf8">
</head>

<body onload="grokdoc.onLoad();">

<div id="header">
  <div class="g-section g-tpl-50-50 g-split">
    <div class="g-unit g-first">
      <a id="logo" href="index.html">Closure Library API Documentation</a>
    </div>

    <div class="g-unit">
      <div class="g-c">
        <strong>Go to class or file:</strong>
        <input type="text" id="ac">
      </div>
    </div>
  </div>
</div>

<div class="clear"></div>

<h2><a href="closure_goog_testing_editor_fieldmock.js.html">fieldmock.js</a></h2>

<pre class="prettyprint lang-js">
<a name="line1"></a>// Copyright 2008 The Closure Library Authors. All Rights Reserved.
<a name="line2"></a>//
<a name="line3"></a>// Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
<a name="line4"></a>// you may not use this file except in compliance with the License.
<a name="line5"></a>// You may obtain a copy of the License at
<a name="line6"></a>//
<a name="line7"></a>//      http://www.apache.org/licenses/LICENSE-2.0
<a name="line8"></a>//
<a name="line9"></a>// Unless required by applicable law or agreed to in writing, software
<a name="line10"></a>// distributed under the License is distributed on an &quot;AS-IS&quot; BASIS,
<a name="line11"></a>// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<a name="line12"></a>// See the License for the specific language governing permissions and
<a name="line13"></a>// limitations under the License.
<a name="line14"></a>
<a name="line15"></a>/**
<a name="line16"></a> * @fileoverview Mock of goog.editor.field.
<a name="line17"></a> *
<a name="line18"></a> * @author robbyw@google.com (Robby Walker)
<a name="line19"></a> */
<a name="line20"></a>
<a name="line21"></a>goog.provide(&#39;goog.testing.editor.FieldMock&#39;);
<a name="line22"></a>
<a name="line23"></a>goog.require(&#39;goog.dom&#39;);
<a name="line24"></a>goog.require(&#39;goog.dom.Range&#39;);
<a name="line25"></a>goog.require(&#39;goog.editor.Field&#39;);
<a name="line26"></a>goog.require(&#39;goog.testing.LooseMock&#39;);
<a name="line27"></a>goog.require(&#39;goog.testing.mockmatchers&#39;);
<a name="line28"></a>
<a name="line29"></a>
<a name="line30"></a>
<a name="line31"></a>/**
<a name="line32"></a> * Mock of goog.editor.Field.
<a name="line33"></a> * @param {Window=} opt_window Window the field would edit.  Defaults to
<a name="line34"></a> *     {@code window}.
<a name="line35"></a> * @param {Window=} opt_appWindow &quot;AppWindow&quot; of the field, which can be
<a name="line36"></a> *     different from {@code opt_window} when mocking a field that uses an
<a name="line37"></a> *     iframe. Defaults to {@code opt_window}.
<a name="line38"></a> * @param {goog.dom.AbstractRange=} opt_range An object (mock or real) to be
<a name="line39"></a> *     returned by getRange(). If ommitted, a new goog.dom.Range is created
<a name="line40"></a> *     from the window every time getRange() is called.
<a name="line41"></a> * @constructor
<a name="line42"></a> * @extends {goog.testing.LooseMock}
<a name="line43"></a> * @suppress {missingProperties} Mocks do not fit in the type system well.
<a name="line44"></a> */
<a name="line45"></a>goog.testing.editor.FieldMock =
<a name="line46"></a>    function(opt_window, opt_appWindow, opt_range) {
<a name="line47"></a>  goog.testing.LooseMock.call(this, goog.editor.Field);
<a name="line48"></a>  opt_window = opt_window || window;
<a name="line49"></a>  opt_appWindow = opt_appWindow || opt_window;
<a name="line50"></a>
<a name="line51"></a>  this.getAppWindow();
<a name="line52"></a>  this.$anyTimes();
<a name="line53"></a>  this.$returns(opt_appWindow);
<a name="line54"></a>
<a name="line55"></a>  this.getRange();
<a name="line56"></a>  this.$anyTimes();
<a name="line57"></a>  this.$does(function() {
<a name="line58"></a>    return opt_range || goog.dom.Range.createFromWindow(opt_window);
<a name="line59"></a>  });
<a name="line60"></a>
<a name="line61"></a>  this.getEditableDomHelper();
<a name="line62"></a>  this.$anyTimes();
<a name="line63"></a>  this.$returns(goog.dom.getDomHelper(opt_window.document));
<a name="line64"></a>
<a name="line65"></a>  this.usesIframe();
<a name="line66"></a>  this.$anyTimes();
<a name="line67"></a>
<a name="line68"></a>  this.getBaseZindex();
<a name="line69"></a>  this.$anyTimes();
<a name="line70"></a>  this.$returns(0);
<a name="line71"></a>
<a name="line72"></a>  this.restoreSavedRange(goog.testing.mockmatchers.ignoreArgument);
<a name="line73"></a>  this.$anyTimes();
<a name="line74"></a>  this.$does(function(range) {
<a name="line75"></a>    if (range) {
<a name="line76"></a>      range.restore();
<a name="line77"></a>    }
<a name="line78"></a>    this.focus();
<a name="line79"></a>  });
<a name="line80"></a>
<a name="line81"></a>  // These methods cannot be set on the prototype, because the prototype
<a name="line82"></a>  // gets stepped on by the mock framework.
<a name="line83"></a>  var inModalMode = false;
<a name="line84"></a>
<a name="line85"></a>  /**
<a name="line86"></a>   * @return {boolean} Whether we&#39;re in modal interaction mode.
<a name="line87"></a>   */
<a name="line88"></a>  this.inModalMode = function() {
<a name="line89"></a>    return inModalMode;
<a name="line90"></a>  };
<a name="line91"></a>
<a name="line92"></a>  /**
<a name="line93"></a>   * @param {boolean} mode Sets whether we&#39;re in modal interaction mode.
<a name="line94"></a>   */
<a name="line95"></a>  this.setModalMode = function(mode) {
<a name="line96"></a>    inModalMode = mode;
<a name="line97"></a>  };
<a name="line98"></a>};
<a name="line99"></a>goog.inherits(goog.testing.editor.FieldMock, goog.testing.LooseMock);
</pre>


</body>
</html>
